<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>数组算法-排序</title>
</head>
<body>
<script>
console.log('----------------------排序-冒泡排序算法(顺序)----------------------');
Array.prototype.sort01 = function () {
	const ret = this;
	let len = ret.length;

	for(let i = 0; i < len; i++) {
		for(let j = 0; j < len - i; j++) {
			if(ret[j] > ret[j+1]) {// 执行交换
				let item = ret[j];
				ret[j] = ret[j+1];
				ret[j+1] = item;
			}
		}
	}
	return ret;
};
console.log([8, 6, 9, 2, 4, 5, 5].sort01());
</script>
</body>
</html>